package co.gov.medellin.ssti.sub.service;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collection;

import javax.naming.NamingException;

import co.gov.medellin.ssti.sub.common.ConexionFactory;
import co.gov.medellin.ssti.sub.model.dao.DAOFactory;
import co.gov.medellin.ssti.sub.model.dao.IReportTotalBenBerDAO;
import co.gov.medellin.ssti.sub.model.dao.exception.DAOException;
import co.gov.medellin.ssti.sub.model.vo.RepDetBeneficiarioVO;
import co.gov.medellin.ssti.sub.model.vo.ReportTotalBenBerVO;

public class ReportTotalBENBERService {
	/**
	 * 
	 * @param criterea
	 * @return
	 * @throws DAOException
	 */
	public Collection<ReportTotalBenBerVO> findBeneficiosBeneficiarios(
			RepDetBeneficiarioVO criterea) throws DAOException {
		IReportTotalBenBerDAO reportTotalBenBerDAO = null;
		try {
			Connection con = ConexionFactory.getInstance().getConnection();
			reportTotalBenBerDAO = DAOFactory.getDAOFactory(DAOFactory.ORACLE)
					.getReportTotalBenBerDAO(con);
			return reportTotalBenBerDAO.findBeneficiosBeneficiarios(criterea);
		} catch (NamingException e) {
			throw new DAOException(e);
		} catch (SQLException e) {
			throw new DAOException(e);
		} finally {
			if (reportTotalBenBerDAO != null) {
				if (!reportTotalBenBerDAO.isConnClosed()) {
					reportTotalBenBerDAO.close();
				}
			}
		}
	}

	/**
	 * 
	 * @param objRtbbVO
	 * @return
	 * @throws DAOException
	 */
	public RepDetBeneficiarioVO findFilters(RepDetBeneficiarioVO objRtbbVO)
			throws DAOException {
		IReportTotalBenBerDAO reportTotalBenBerDAO = null;
		try {
			Connection con = ConexionFactory.getInstance().getConnection();
			reportTotalBenBerDAO = DAOFactory.getDAOFactory(DAOFactory.ORACLE)
					.getReportTotalBenBerDAO(con);
			return reportTotalBenBerDAO.findFilters(objRtbbVO);
		} catch (NamingException e) {
			throw new DAOException(e);
		} catch (SQLException e) {
			throw new DAOException(e);
		} finally {
			if (reportTotalBenBerDAO != null) {
				if (!reportTotalBenBerDAO.isConnClosed()) {
					reportTotalBenBerDAO.close();
				}
			}
		}
	}
}
